/* The file is saved in UTF-8 codepage.
 * Check: «Stereotype», Section mark-§, Copyright-©, Alpha-α, Beta-β, Smile-☺
 */
package cz.pecinovsky.english.lootp._115_;

import cz.pecinovsky.english.lootp._000_.Run;

import cz.pecinovsky.english.lootp.manager.Rectangle;
import cz.pecinovsky.english.lootp.manager.Mover;


import cz.pecinovsky.english.lootp.manager.CanvasManager_Envelope.               CanvasManager;

// %I + <119
//import cz.pecinovsky.english.lootp.shapes.Rectangle;
// %I -

import cz.pecinovsky.english.lootp.utility.NamedColor;
import cz.pecinovsky.english.lootp.utility.IO;


//import cz.pecinovsky.english.lootp._115_.Arrow_119_116.Arrow;
import cz.pecinovsky.english.lootp._115_.Arrow_120_124.Arrow;



//import cz.pecinovsky.english.lootp._115_.Empty_115_116.Empty;
////////////////////////////////////////////////////////////////////////////////
//%%+  +++++ End of ignored starting test - place for imports +++++

//%X+ xxxxx Start of the ovejumped text with declaration of the envelope xxxxx
/*******************************************************************************
 *<pre>
 * Previous:  No - this is a newly defined class
 * Following: No
 *
 * Project  016z_02_Tvary
 *   + Two constructors
 *
 *</pre>
 *
 * @author Rudolf PECINOVSKÝ
 * @version 6.03.2017 — 2010-11-08
 */
/*******************************************************************************
 *<pre>
 * Předchozí: Není__Toto_je_nově_definovaná_třída
 *
 * Přidáno:
 *      *
 * Upraveno:
 *      *
 *</pre>
 */
public class ArrowTest_117_124
{    private ArrowTest_117_124() {}     static
//%X- ----- End of the ovejumped text with declaration of the envelope -----


/*******************************************************************************
 * Testovací třída {@code ArrowTest}  slouží ke komplexnímu otestování
 * třídy {@link ArrowTest}.
 *
 * @author Rudolf PECINOVSKÝ
 * @version 6.03.2017 — 2010-11-08
 */
public class ArrowTest extends junit.framework.TestCase
{
//%A+ >119
    private CanvasManager CM;
//%A-
    private Arrow arrow0;
    private Arrow arrowXY;
    private Arrow arrowXYB;
//%A+ >122
    private Arrow arrowXYP;
    private Arrow arrowXYPB;
//%A-



//== CONSTANT CLASS ATTRIBUTES =================================================
//== VARIABLE CLASS ATTRIBUTES =================================================
//== STATIC CONSTRUCTOR (CLASS INITIALIZER, STATIC INICITALIZING BLOCK) ========
//== CONSTANT INSTANCE ATTRIBUTES ==============================================
//== VARIABLE INSTANCE ATTRIBUTES ==============================================
//== CLASS GETTERS AND SETTERS =================================================
//== OTHER NON-PRIVATE CLASS METHODS ===========================================

//##############################################################################
//== CONSTUCTORS AND FACTORY METHODS ===========================================

    /***************************************************************************
     * Vytvoří test se zadaným názvem.
     *
     * @param name  Název konstruovaného testu
     */
    public ArrowTest(String name)
    {
        super(name);
    }



//== PREPARATION AND CLEANING THE FIXTURE ======================================

    /***************************************************************************
     * Inicializace předcházející spuštění každého testu a připravující tzv.
     * přípravek (fixture), což je sada objektů, s nimiž budou testy pracovat.
     */
    @Override
    protected void setUp()
    {
        arrow0     = new Arrow();
        arrowXY    = new Arrow(50,  50);
        arrowXYB   = new Arrow(100, 100, NamedColor.BLUE);
//%A+ >122
        arrowXYP   = new Arrow(  0, 100, 100);
        arrowXYPB  = new Arrow(100,   0, 100, NamedColor.BLUE);
//%A-
//%A+ >119

        CM = CanvasManager.getInstance();
        CM.add(arrow0);
        CM.add(arrowXY);
        CM.add(arrowXYB);
//%A-
//%A+ >122
        CM.add(arrowXYP);
        CM.add(arrowXYPB);
//%A-

        IO.inform("Arrows prepared");
    }


    /***************************************************************************
     * Úklid po testu - tato metoda se spustí po vykonání každého testu.
     */
    @Override
    protected void tearDown()
    {
    }


//== PRIVATE AND AUXILIARY CLASS METHODS =======================================
//== PRIVATE AND AUXILIARY INSTANCE METHODS ====================================
//%A+ >123

    /***************************************************************************
     * Vyzkouší změny pozice a velikosti zadaného auta
     */
    private void auxPositionSize(Arrow arrow)
    {
        final int ms = 500;
        arrow.setPosition(150, 150);
        IO.pause(ms);
        arrow.setModule(150);
        IO.pause(ms);
        arrow.setModule(25);
        IO.pause(ms);
        CM.remove(arrow);
        IO.pause(ms);
    }

//%A-
//%A+ >123


//%A-
//== EMBEDDED TYPES AND INNER CLASSES ==========================================
//== THE TESTS =================================================================
//
//     /***************************************************************************
//      *
//      */
//     public void testXXX()
//     {
//     }
//%A+ >118


    public void testTranslucent()
    {
        Rectangle ground = new Rectangle(25, 25, 100, 100, NamedColor.WHITE);
//%A-
//%A+ >119
        CM.addBehind(arrow0, ground);

//%A-
//%A+ >118
        arrow0   .translucent();
        arrowXY  .translucent();
        arrowXYB .translucent();
//%A-
//%A+ >122
        arrowXYP .translucent();
        arrowXYPB.translucent();
//%A-
//%A+ >118

        IO.inform("Verify translucency");

        arrow0   .restoreColor();
        arrowXY  .restoreColor();
        arrowXYB .restoreColor();
//%A-
//%A+ >122
        arrowXYP .restoreColor();
        arrowXYPB.restoreColor();
//%A-
//%A+ >118
     }
//%A-
//%A+ >124


    public void testSmoothMovement()
    {
        arrow0   .translucent();
        arrowXY  .translucent();
        arrowXYB .translucent();
        arrowXYP .translucent();
        arrowXYPB.translucent();
        Mover p = new Mover(10);
        p.moveTo(250,   0, arrow0);
        p.moveTo(250,  50, arrowXY);
        p.moveTo(250, 100, arrowXYB);
        p.moveTo(200, 100, arrowXYP);
        p.moveTo(200,   0, arrowXYPB);
    }
//%A-
//%A+ >123


    public void testPositionSize()
    {
        auxPositionSize(arrow0);
        auxPositionSize(arrowXY);
        auxPositionSize(arrowXYB);
        auxPositionSize(arrowXYP);
        auxPositionSize(arrowXYPB);
    }
//%A-
//%X+
     /** */
     public void testFixture() {}
//%X-
    }
//%%- ---- Start of the ovejumped text with closing of the envelope ----
//%== //Takto se označí řádek, jenž bude odkomentován (vhodné např. pro importy)
//Je-li na 6 pozici mezera, odmaže se také

//== TESTING CLASSES AND METHODS ===============================================

    /***************************************************************************
     * Třída, jejíž instance má na starosti úklid mezi jednotlivými testy,
     * který není možno zakomponovat do metody {@code tearDown()},
     * dokud nebudou studenti umět programovat.
     */
    private static class TearDown implements Run.ITD
    {
        /** {@inheritDoc} */
        @Override
        public void cleanUp()
        {
//            Canvas.clearCanvas();
//            CanvasManager.getInstance().removeAll();
        }
    }


    /***************************************************************************
     * Test method.
     */
    public static void test()
    {
        Run.tests(ArrowTest.class,
                new TearDown(),
//                "testFixture",
//                "testTranslucent",
//                "testPositionSize",
                "testSmoothMovement",
                "");
        System.exit(0);
    }
    /** @param args Parametry příkazového řádku - nepoužívané. */
    public static void main(String[] args)  {  test();  }
}
